<?php $__env->startSection('title','学术成果上传'); ?>
<?php $__env->startSection('css'); ?>
<link href="<?php echo e(asset(getThemeAssets('css/toastr.min.css'))); ?>" rel="stylesheet">
<style type="text/css">
    .widget .row span{
      font-size: 15px;
      font-weight: bold;
    }
    .p-md{
        padding-top: 6px;
        padding-bottom: 0px;
        margin-top: 0px;
        margin-bottom: 30px;
    }
    .m-b-md{
        padding-top: 3px;
    }
    .page-heading{
        padding-bottom: 2px;
    }
    .alert{
        /*padding-bottom: 0px;*/
        padding-left: 23px;
        padding-right: 23px;
        margin-bottom: 0px;
    }
    .alert p{
        font-size: 14px;
        font-weight: 12px;
    }
    .alert a{
        text-decoration: underline;
    }
    .canceled{
        margin: 0;
        padding: 0;
    }
    #login-form {
        margin-top: 30px;
    }
    #login-form img{
        width: 100%;
        margin-left: 0;
    }
    #footerrow {
      margin-top: 100px;
    }
    .col-sm-6 {
      padding: 3px;
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

<div class="row wrapper border-bottom page-heading">
  <div class="col-sm-10">
    <h2><?php echo trans('upload.AcademicTitle'); ?></h2>
    <ol class="breadcrumb">
        <li>
            <a href="<?php echo e(url('admin')); ?>"><?php echo trans('home.title'); ?></a>
        </li>
        <li class="active">
            <strong><?php echo trans('upload.AcademicTitle'); ?></strong>
        </li>
    </ol>
  </div>
  <div class="col-sm-2">
    <div class="title-action">
      <a class="btn btn-primary btn-block" href="<?php echo e(url('/admin/upload/uploadAcademicExcel')); ?>"><i class="fa fa-reply"></i>切换Excel方式上传</a>
    </div>
  </div>
</div>
<div id="login-form">
    <div class="logo">
        <img id="logo" src="<?php echo e(asset(getThemeAssets('img/logo2.png'))); ?>">
    </div>
    <div class="row">
        
      <form class="form-horizontal" id="awardinfo" enctype="multipart/form-data" method="" action="">
      <?php echo e(csrf_field()); ?>

        <div class="col-lg-offset-3 col-lg-6">
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-user"></span> -->
              <label>第一作者：</label>
            </div>
            <input type="text" class="form-control" id="first_author" name="first_author"
                    placeholder="" required>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-user"></span> -->
              <label>职工编号：</label>

            </div>
            <input type="text" class="form-control" id="jobnumber" name="jobnumber"
                    placeholder="" required>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-star"></span> -->
              <label>学术成果名称：</label>

            </div>
            <input type="text" class="form-control" id="academic_name" name="academic_name" placeholder="" required>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-star"></span> -->
              <label>学术分类：</label>

            </div>
            <select class="form-control" id="academic_category" name="academic_category">
                <option class="form-control" value ="学术论文">学术论文</option>
                <option class="form-control" value ="学术专著">学术专著</option>
                <option class="form-control" value="专利">专利</option>
                <option class="form-control" value="艺术作品">艺术作品</option>
              </select>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-time"></span> -->
              <label>具体类别：</label>

            </div>
            <select class="form-control" id="specific_category" name="specific_category">
                <option class="form-control" value ="SCI">SCI</option>
                <option class="form-control" value ="EI">EI</option>
                <option class="form-control" value ="ISTP">ISTP</option>
                <option class="form-control" value ="人大复印">人大复印</option>
                <option class="form-control" value ="新华文摘转载">新华文摘转载</option>
                <option class="form-control" value ="其它核心">其它核心</option>
                <option class="form-control" value ="一般论文">一般论文</option>
                <option class="form-control" value ="专著">专著</option>
                <option class="form-control" value ="译著">译著</option>
                <option class="form-control" value ="编著">编著</option>
                <option class="form-control" value ="其他类学术专著">其他类学术专著</option>
                <option class="form-control" value ="发明专利">发明专利</option>
                <option class="form-control" value ="实用新型专利">实用新型专利</option>
                <option class="form-control" value ="外观设计专利">  
外观设计专利</option>
                <option class="form-control" value ="软件著作权">  
软件著作权</option>
                <option class="form-control" value ="其他类专利">其他类专利</option>
                <option class="form-control" value ="艺术作品">艺术作品</option>
            </select>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-tag"></span> -->
              <label>发表刊物/出版社/授权单位：</label>

            </div>
            <input type="text" class="form-control" id="publication" name="publication" placeholder="" required>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-star"></span> -->
              <label>发表时间/出版时间/授权时间（年/月）：</label>

            </div>
            <input type="date" class="form-control" id="published_date" name="published_date" placeholder="" required>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-star"></span> -->
              <label>其他成员：</label>

            </div>
            <input type="text" class="form-control" id="other_mumbers" name="other_mumbers" placeholder="成员以逗号分割，可以为空" required>
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-time"></span> -->
              <label class="input-group">是否被转让或采用（仅限于专利）：</label>

            </div>
            <select class="form-control" id="is_transfered">
                <option class="form-control" value ="否">否</option>
                <option class="form-control" value ="是">是</option>
              </select>
          </div>
        </div>
                <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <!-- <span class="glyphicon glyphicon-tag"></span> -->
              <label>证书文件：</label>

            </div>
            <input type="file" class="form-control" accept="image/jpg,image/jpeg,image/png" id="uploadimg" name="certificate_url" multiple />
            <div id="preview">
              
            </div>
          </div>
        </div> 
        </div>
        
        <div class="form-group">
          <div class="col-sm-12 ">
            
            <div class="col-sm-offset-3 col-sm-3">
                <button type="button" id="submitbtn" class="btn btn-primary btn-block">确认提交学术成果记录</button>
            </div>
            <div class="col-sm-3">
                <a href="<?php echo e(url('/admin/upload/uploadAcademicExcel')); ?>">
                <button type="button" class="btn btn-primary btn-block">切换为Excel文件上传</button>
                </a>
            </div>
          </div>
        </div>
      </form>
  </div>
</div>
                        

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
<script src="<?php echo e(asset(getThemeAssets('js/toastr.min.js'))); ?>"></script>
<script type="text/javascript">
    $(document).ready(function()  {
        $("#uploadimg").change(function() {
            var file;
            var destination;
            destination = $("#preview");
            destination.innerHTML = ''; // 预览区置空
            // 循环遍历用户选择的文件
            for (var x=0,xlen = this.files.length;x<xlen;x++) {
                file = this.files[x];
                // 对上传文件大小做限制 200kb
                if (file.size > 204800) {
                  swal("请上传图片大小不要超过200KB！","","warning");
                  $("#uploadimg").val("");
                  $("#preview").html("");
                  return;
                }
                if (file.type.indexOf('image') != -1) { // 判断是否为图片
                    var reader = new FileReader(); // 预览对象
                    reader.readAsDataURL(file);
                    reader.onload = function(e) {
                        var img = new Image();
                        img.src = e.target.result;
                        destination.append(img);
                    }
                }
            }
        });
      // 上传事件监听
      $("#submitbtn").click(function() {
          var awardInfo = [];
          awardInfo['first_author'] = $("#first_author").val();
          awardInfo['jobnumber'] = $("#jobnumber").val();
          awardInfo['academic_name'] = $("#academic_name").val();
          awardInfo['academic_category'] = $("#academic_category").val();
          awardInfo['specific_category'] = $("#specific_category").val();
          awardInfo['publication'] = $("#publication").val();
          awardInfo['published_date'] = $("#published_date").val();
          awardInfo['other_mumbers'] = $("#other_mumbers").val();
          awardInfo['is_transfered'] = $("#is_transfered").val();
          if (awardInfo['first_author'] == '') {
              swal("第一作者不能为空","","warning");
              return;
          }
          if (awardInfo['jobnumber'] == '') {
              swal("职工编号不能为空","","warning");
              return;
          }
          if (awardInfo['academic_name'] == '') {
              swal("学术成果名称不能为空！","","warning");
              return;
          }
          if (awardInfo['academic_category'] == '') {
              swal("学术成果分类不能为空！","","warning");
              return;
          }
          if (awardInfo['specific_category'] == '') {
              swal("具体分类不能为空！","","warning");
              return;
          }
          if (awardInfo['publication'] == '') {
              swal("出版社/发表刊物/授予单位 不能为空！","","warning");
              return;
          }
          if (awardInfo['published_date'] == '') {
              swal("出版日期不能为空！","","warning");
              return;
          }
          // 对不上传图片文件进行用户提示
          if ($("#uploadimg").val() == "") {
              swal("对不起！请至少上传一张小于200KB的图片证明文件。","","warning");
              $("#preview").html("");
              return;
          }
          var allFiles = document.querySelector("#uploadimg").files;
          // 实例化表单数据对象
          var formData = new FormData();
          // 遍历图片文件列表并插入至表单中
          for (var i=0,file;file = allFiles[i];i++) {
              // 包含文件名称和文件对象
              formData.append(file.name,file);
          }
          console.log(awardInfo);
          // 实例化表单数据对象
          var formData = new FormData();
          formData.append('first_author',awardInfo['first_author']);
          formData.append('jobnumber',awardInfo['jobnumber']);
          formData.append('academic_name',awardInfo['academic_name']);
          formData.append('academic_category',awardInfo['academic_category']);
          formData.append('specific_category',awardInfo['specific_category']);
          formData.append('publication',awardInfo['publication']);
          formData.append('published_date',awardInfo['published_date']);
          formData.append('other_mumbers',awardInfo['other_mumbers']);
          formData.append('is_transfered',awardInfo['is_transfered']);
          console.log(formData);
          // ajax请求，向数据库进行信息提交
          $.ajaxSetup ({
                     headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
            });

          $.ajax({
              url: "<?php echo e(url('/admin/upload/uploadAcademic')); ?>",
              type: 'post',
              data: formData,
              processData: false,
              contentType: false, 
              success: function(res) {
                  if (res['res'] == 1) {
                      swal("上传学术成果记录成功！请到个人档案进行核对！","","success");
                      $("#first_author").val("");
                      $("#jobnumber").val("");
                      $("#academic_name").val("");
                      $("#academic_category").val("");
                      $("#publication").val("");
                      $("#published_date").val("");
                      $("#other_mumbers").val("");
                      $("#preview").val("");
                  }else {
                      swal("上传失败！请联系管理员！","","warning");
                  }
              }
          });

      });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.'.getTheme(), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>